package cn.xuewenbao.edu.controller;


import cn.xuewenbao.edu.entity.vo.ContentDataVo;
import cn.xuewenbao.edu.service.ColumnDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

/**
 * <p>
 * 专栏数据表 前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-04-21
 */
@RestController
@RequestMapping("/edu/columndata")
@Api(tags = "内容数据表")
public class ColumnDataController {

    @Autowired
    private ColumnDataService dataService;

    //根据内容id返回内容数据（点赞，收藏）
    @ApiOperation(value = "根据内容id返回内容数据（点赞，收藏）")
    @GetMapping("getContentData/{contentId}")
    public Result<ContentDataVo> getColumnData(@PathVariable String contentId) {
        Result<ContentDataVo> result = dataService.getContentData(contentId);
        return result;
    }

    @ApiOperation(value = "test yesterday like count")
    @GetMapping("getLikeCount/{userId}")
    public Result<Map<String, Long>> getLikeCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = dataService.getLikeCount(userId);
        return result;
    }

    //根据作者的id获取总阅读量
    @ApiOperation("根据作者的id获取总阅读量")
    @GetMapping("getAllViewCpunt/{userId}")
    public Result<Integer> getAllViewCount(@PathVariable String userId){
        Result<Integer> result = dataService.getAllViewCount(userId);
        return result;
    }
}

